
<!-- You can start editing here. -->
{% if entry.allow_comment %}
	{% if entry.comments.count%}
		<h3 id="comments">{{entry.comments.count}} Responses to &#8220;{{entry.title}}&#8221;</h3>

		<ol class="commentlist">

		{% for comment in entry.comments %}
			<li class="{%cycle alt1,alt %}" id="comment-{{comment.key.id}}">
				<a class="gravatar"><img height="60px" width="60px" class="avatar avatar-50" src="{{comment.gravatar_url}}" alt=""/></a>
				
				<div class="commentbody">                                       
				<cite>{%if comment.weburl %}<a class="url" target="_blank" href="{{comment.weburl}}">{{comment.author}}</a>{% else %}{{comment.author}}{%endif%}</cite>
				<br />
				<small class="commentmetadata"><a href="#comment-{{comment.key.id}}" title="">{{comment.date.date|datetz:"Y-m-d"}} on {{comment.date|datetz:"H:i"}}</a> <a onclick="return backcomment('<a href=#comment-{{comment.key.id}}>{{comment.author}}</a>');" href="#commentarea"><span color="blue">Reply</span></a> </small>
                    
				<br />
				<p>{{comment.content|safe }}</p>
				</div>

				<div class="cleared"></div><!-- clears the floats so the backgrounds show all the way down -->
			</li>
		{%endfor%}

		</ol>
	{%endif%}
<div class="cleared"></div>
<a name="commentarea"></a>
<h3>Leave a Reply</h3>
<script type="text/javascript">
function backcomment(msg){
backdb=document.getElementById('comment');
backdb.value= backdb.value.concat("@", msg, "\n");
return true;
}
</script>
<form action="/post_comment" method="post" id="commentform">

	<p><input type="text" name="author" id="author" value="{{user_name}}" size="22" tabindex="1" />
	<label for="author"><small>Name (required)</small></label></p>

	<p><input type="text" name="email" id="email" value="{{user_email}}" size="22" tabindex="2" />
	<label for="email"><small>Mail (will not be published) (required)</small></label></p>

	<p><input type="text" name="url" id="url" value="{{user_url}}" size="22" tabindex="3" />
	<label for="url"><small>Website</small></label></p>

    <p><input type="checkbox" name="reply_notify_mail" id="reply_notify_mail" checked="checked" size="45" tabindex="4" />
    <label for="reply_notify_mail"><small>Send me reply notify mail</small></label></p>

		{%ifequal blog.comment_check_type 1%}
		<p id="checkarea">
		<iframe style="width:80px;height:20px;border:0;" scrolling="no" src="/checkcode/" frameborder="0" >
		</iframe>
		<input type="text" name="checkret" id="checkret" value="" size="5" tabindex="5" />
		</p>
		{%endifequal%}

		{%ifequal blog.comment_check_type 2%}
		<div id="checkarea" style="padding-bottom:15px">
		<div style="float:left;margin-right:8px;"><label for="checkret"><small>Checkcode:</small></label>
		<input type="text" name="checkret" id="checkret" value="" size="5" tabindex="5" />
		</div>
		<img id='checkimg' src='/checkimg/' style="border:0px;padding:0px;" title='Click to change image' onclick="reloadCheckImage();"/>
		</div>
		{%endifequal%}

	<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="6"></textarea></p>

	<p><input name="submit" type="submit" id="submit" class="submitbutton" tabindex="7" value="Leave comment" />
	</p>
	<input type="hidden" name="key" value="{{entry.key}}" />
</form>
<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
<script>
   commentuser=$.cookie('comment_user');
   if (commentuser)
   {
    //[user,email,url]=commentuser.split('#@#');
    var tuple=commentuser.split('#@#');
    var user,email,url;
    user=tuple[0];
    email=tuple[1];
    url=tuple[2];

     $('#author').val(user);
     $('#email').val(email);
     $('#url').val(url);
   }

  $('#commentform').submit(function(){
         var form = this;
           if (form.author)
  		   {

      			 if (!form.author.value)
          		 {
          		  alert('Please input your name.');
          		  form.author.focus();
          		  return false;
          		 }
          		 if (!form.email.value)
          		 {
          		 	alert('Please input the email address.');
          		 	form.email.focus();
          		 	return false;
          		 }
	       }

      		 if (!form.comment.value)
      		 {
      		 	alert('Please leave some reply message.');
      		 	form.comment.focus();
      		 	return false;
      		 }

      		 return true;
  });
</script>

{% else %}

<p class="nocomments">Comments are closed.</p>

{% endif %}
